<!--#include file="functions.asp" -->
<%

'set cn=Server.CreateObject("ADODB.Connection")
'cn.Open "MP2ENTTEST2", "MP2", "MP2"
dim sql, varlevel

select case request("Level")
  case "Executive Directors"
    varLevel = 1
  case "Business Unit Manager"
    varLevel = 2
  case "Manager"
    varLevel = 4
  case "Managers/Senior Staff"
    varLevel = 6 
  case Else
    varLevel = 0	
end select

if (request("seqnum") = "0") then
  sql = "INSERT INTO EXIAUTHORITY (AUTHDESCR, LEVELDESC, GROUPDESC, MANAGERNAME, LOGINNAME, EMPCODE, INITIALS, ISDOA, DOATO, DOANAME, DEPARTMENT, LEVELNUM) VALUES('"
  sql = sql & request("Authority") & "','"
  sql = sql & request("level") & "','"
  sql = sql & request("Group") & "','"
  sql = sql & dblq(request("Name") )& "','"
  sql = sql & request("reqLoginname") & "','"
  sql = sql & request("empCode") & "','"
  sql = sql & request("Initial") & "','"
  if (request("Delegate")="Y") then
  sql = sql & "Y','"
  else
  sql = sql & "N','"
  end if
  sql = sql & request("DOA") & "','"
  sql = sql & request("DOAName") & "','"
  sql = sql & request("Dept") & "',"
  sql = sql & varLevel & ")"
else
  sql = "UPDATE EXIAUTHORITY SET "
  sql = sql & "AUTHDESCR='" & request("Authority") & "',"
  sql = sql & "LEVELDESC='" & request("level") & "',"
  sql = sql & "GROUPDESC='" & request("Group") & "',"
  sql = sql & "MANAGERNAME='" & dblq(request("Name")) & "',"
  sql = sql & "LOGINNAME='" & request("reqLoginname") & "',"
  sql = sql & "EMPCODE='" & request("empCode") & "',"
  sql = sql & "INITIALS='" & request("Initial") & "',"
  if (request("Delegate")="Y") then
  sql = sql & "ISDOA='Y',"
  sql = sql & "DOATO='" & request("DOA") & "',"
  sql = sql & "DOANAME='" & request("DOAName") & "',"
  else
  sql = sql & "ISDOA='N',"
  sql = sql & "DOATO='',"
  sql = sql & "DOANAME='',"
  end if
  'sql = sql & "DOATO='" & request("DOA") & "',"
  'sql = sql & "DOANAME='" & request("DOAName") & "',"
  sql = sql & "DEPARTMENT='" & request("Dept") & "',"
  sql = sql & "LEVELNUM=" & varLevel 
  sql = sql & " WHERE SEQNUM =" & request("seqnum")

end if
cn.execute(sql)

%>
<script language="VBScript">
window.opener.parent.location.reload
window.close
</script>
